package tcpserver.handler;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;
import tcpserver.handler.in.*;
import tcpserver.handler.out.FrameEncoder;
import tcpserver.handler.out.SessionCleaner;

public class RFIDChannelInitializer extends ChannelInitializer<SocketChannel> {

    @Override
    protected void initChannel(SocketChannel ch) throws Exception {

        // Channel In Bound Handlers

        ch.pipeline().addLast(SessionHandler.class.getName(), new SessionHandler())
                     .addLast(FrameSeparator.class.getName(), new FrameSeparator())
                     .addLast(InterceptorOfHeartBeats.class.getName(), new InterceptorOfHeartBeats())
                     .addLast(FrameDecoder.class.getName(), new FrameDecoder())
                     .addLast(FrameCollector.class.getName(), new FrameCollector())
                     .addLast(FrameLimiter.class.getName(), new FrameLimiter());

        // Channel Out Bound Handlers

        ch.pipeline().addFirst(SessionCleaner.class.getName(), new SessionCleaner())
                     .addFirst(FrameEncoder.class.getName(), new FrameEncoder());
    }
}
